package org.finesys.chat.core.base.embedding.filter.compairson;

import java.util.Collection;
import java.util.UUID;

public class UUIDComparator {


    static boolean containsAsUUID(Object actualUUID, Collection<?> comparisonUUIDs) {
        UUID uuid = toUUID(actualUUID);
        return comparisonUUIDs.stream().map(UUIDComparator::toUUID).anyMatch((comparisonUUID) -> {
            return comparisonUUID.compareTo(uuid) == 0;
        });
    }

    private static UUID toUUID(Object actualUUID) {
        if (actualUUID instanceof String) {
            return UUID.fromString(actualUUID.toString());
        } else if (actualUUID instanceof UUID) {
            UUID iD = (UUID) actualUUID;
            return iD;
        } else {
            throw new IllegalArgumentException("Unsupported type: " + actualUUID.getClass().getName());
        }
    }
}


